const state = {
    list: [],
    page: {},
    domains: [],
    orgs: []
}
const actions = {
    save_expert: ({ commit }, payload) => {
        commit('SAVEEXPERT', payload)
    },
    save_domain: ({ commit }, payload) => {
        commit('SAVEDOMAIN', payload)
    },
    save_orgs: ({ commit }, payload) => {
        commit('SAVEORGS', payload)
    }
}
const mutations = {
    SAVEEXPERT: (state, payload) => {
        const data = payload.result
        if (data.legth === 0) {
            state.list = []
        } else {
            state.list = data.map(item => {
                return {
                    id: item.id,
                    state: item.state,
                    name: item.name,
                    nameChar: item.name_char,
                    organizationId: item.organization_id,
                    img: item.head_img,
                    job: item.job,
                    ranking: item.ranking,
                    edu: item.edu,
                    report: item.report,
                    paper: item.paper,
                    book: item.book,
                    research_field_list: item.research_field_list
                }
            })
        }
        state.page = {
            size: 10,
            number: payload.number || 1,
            total: payload.resultNum
        }
    },
    SAVEDOMAIN: (state, payload) => {
        state.domains = payload.result
    },
    SAVEORGS: (state, payload) => {
        state.orgs = payload.result
    }
}
const getters = {
    getExpert: state => state.result
}
export default {
    state,
    getters,
    actions,
    mutations
}